package com.common.dto;

import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;

import com.common.dto.base.BaseDTO;


/**
 * 字典表实体
 * 
 * @author zp
 *
 */
@XmlRootElement
@Table(name = "dict_item")
public class DictionaryDTO extends BaseDTO {
	
	private static final long serialVersionUID = 6067040503978336745L;

	/**
	 * 地点编号
	 */
	@Column(name="item_code")
	private String itemCode;

	/**
	 * 地点名称
	 */
	@Column(name="item_name")
	private String itemName;

	/**
	 * 地点类型
	 */
	@Column(name="type_code")
	private String typeCode;

	/**
	 * 状态
	 */
	private String status;

	/**
	 * 父类编号
	 */
	@Column(name="parent_id")
	private String parentCode;
	
	@Transient
	private String directs;//指示状态
	@Transient
	private String yestData;//原来的状态
	@Transient
	private String nowData;//现在的状态
	
	
	
	public String getYestData() {
		return yestData;
	}

	public void setYestData(String yestData) {
		this.yestData = yestData;
	}

	public String getNowData() {
		return nowData;
	}

	public void setNowData(String nowData) {
		this.nowData = nowData;
	}

	public String getDirects() {
		return directs;
	}

	public void setDirects(String directs) {
		this.directs = directs;
	}

	public String getItemCode() {
		return itemCode;
	}

	public void setItemCode(String itemCode) {
		this.itemCode = itemCode;
	}

	public String getItemName() {
		return itemName;
	}

	public void setItemName(String itemName) {
		this.itemName = itemName;
	}

	public String getTypeCode() {
		return typeCode;
	}

	public void setTypeCode(String typeCode) {
		this.typeCode = typeCode;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getParentCode() {
		return parentCode;
	}

	public void setParentCode(String parentCode) {
		this.parentCode = parentCode;
	}

	/**
	 * @function 将获取从SCM获取到的仓位记录转化为字典表实体
	 * @param structAttrMap
	 * @return
	 * @data 2017-9-22
	 * @author zhongpeng
	 */
	@SuppressWarnings("rawtypes")
	public DictionaryDTO transformFromStructAttr(Map structAttrMap){
		
		//获取仓位ID
		String id = (String) structAttrMap.get("structuuid");
		
		//获取仓位对应EASID
		String itemCode = (String) structAttrMap.get("externalid");
		
		//获取仓位对应库区ID
		String parentCode = (String) structAttrMap.get("sectuuid");
		
		//获取仓位名称
		String itemName = (String) structAttrMap.get("structname");
		
		//返回转换后的字典表实体
		DictionaryDTO dictionaryDTO = new DictionaryDTO();
		dictionaryDTO.setId(id);
		dictionaryDTO.setItemCode(itemCode);
		dictionaryDTO.setParentCode(parentCode);
		dictionaryDTO.setItemName(itemName);
		
		return dictionaryDTO;
	}
	
	/**
	 * @function 将获取从SCM获取到的库区记录转化为字典表实体
	 * @param sectAttrMap
	 * @return
	 * @data 2017-9-22
	 * @author zhongpeng
	 */
	@SuppressWarnings("rawtypes")
	public DictionaryDTO transformFromSectAttr(Map sectAttrMap){
		
		//获取库区ID
		String id = (String) sectAttrMap.get("sectuuid");
		
		//获取对应库区的仓库ID
		String parentCode = (String) sectAttrMap.get("storuuid");
		
		//获取库区对应的EASID
		String itemCode = (String) sectAttrMap.get("externalid");
		
		//获取仓库名称
		String itemName = (String) sectAttrMap.get("sectname");
		
		//返回转换后的字典表实体
		DictionaryDTO dictionaryDTO = new DictionaryDTO();
		
		dictionaryDTO.setId(id);
		dictionaryDTO.setParentCode(parentCode);
		dictionaryDTO.setItemCode(itemCode);
		dictionaryDTO.setItemName(itemName);
		
		return dictionaryDTO;
	}
	
	//获取库点信息
	@SuppressWarnings("rawtypes")
	public DictionaryDTO getStorePoint(Map map){
		DictionaryDTO dictionaryDTO=new DictionaryDTO();
		//库点在SCM的id
		dictionaryDTO.setItemCode((String) map.get("storepointuuid"));
		//库点名称
		dictionaryDTO.setItemName((String) map.get("storepointname"));
		return dictionaryDTO;
	}
	
	//获取仓库信息
	@SuppressWarnings("rawtypes")
	public DictionaryDTO getWarehouse(Map map){
		DictionaryDTO dictionaryDTO=new DictionaryDTO();
		//仓库在SCM的id
		dictionaryDTO.setId((String) map.get("storuuid"));
		//仓库在EAS的id
		dictionaryDTO.setItemCode((String) map.get("externalid"));
		//仓库名称
		dictionaryDTO.setItemName((String) map.get("storename"));
		//仓库对应的库点
		dictionaryDTO.setParentCode((String) map.get("storepointuuid"));
		return dictionaryDTO;
	}
	
	@Override
	public String toString() {
		return "DictionaryDTO [itemCode=" + itemCode + ", itemName=" + itemName + ", typeCode=" + typeCode + ", status="
				+ status + ", parentCode=" + parentCode + "]";
	}



}
